//:C16:OwnerStackTest.cpp
// {L} AutoCounter
#include "AutoCounter.h"
#include "OwnerStack.h"
#include "../require.h"
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main(void)
{
    Stack<AutoCounter> ac;    // Ownership on
    Stack<AutoCounter> ac2(false);    // Turn it off 
    AutoCounter *ap;
    for(int i = 0; i < 10; i++)
    {
        ap = AutoCounter::create();
        ac.push(ap);
        if(i % 2 == 0)
        {
            ac2.push(ap);
        }
    }

    while(ac2)
    {
        cout << ac2.pop() << endl;
    }
    // No destruction necesary since
    // ac "owns" all the objects
}
